<template>
    <section >
        <el-card>
            <el-table
                    :data="k8snamespaces"
                    stripe
                    style="width: 100%"
                    :row-style="rowStyle"
            >
                <el-table-column

                        width="40">
                    <template slot-scope="scope">
                        <i :class="scope.row.status !== 'Active' ? 'fa fa-info-circle' : 'fa fa-check-circle'"
                           :style="scope.row.status !== 'Active' ? 'font-size:18px;color:red' : 'font-size:18px;color:green'"
                        >

                        </i>

                    </template>



                </el-table-column>

                <el-table-column
                        prop="name"
                        label="名称"
                        width="180">
                    <template slot-scope="scope">
                        <el-link :href="'#/kubernetes/namespace/' + scope.row.name"  type="primary" :underline="false" icon="el-icon-s-promotion">{{scope.row.name}}</el-link>
                    </template>
                </el-table-column>


                <el-table-column
                        prop="status"
                        label="状态">
                    <template slot-scope="scope">
                        <el-tag
                                size="mini"
                                :type="scope.row.status !== 'Active' ? 'danger' : 'success'"
                                :style="scope.row.status !== 'Active' ? 'color: red' : 'color: green'"
                                disable-transitions>{{scope.row.status}}</el-tag>
                    </template>

                </el-table-column>

                <el-table-column
                        prop="createdate"
                        label="创建时间">
                </el-table-column>
            </el-table>
        </el-card>
    </section>
</template>

<script>
    import { k8sNamespacesData } from '../../api/api'
    export default {
        data() {
            return {
                k8snamespaces: [],
            }
        },
        methods: {
            rowStyle({ row, rowIndex}){
                return "height:50px;"
            },
            getK8sNamespacesData(){
                let self = this
                k8sNamespacesData().then((res) => {
                    console.log(res)
                    this.k8snamespaces = res.namespaces
                })

            },
        },
        mounted: function () {
            console.log("debug ehrer")
            this.getK8sNamespacesData()

        }
    }
</script>